﻿#include "Football.h"
#include "../../../Shared/Functions/Functions.h"

using namespace Server::MirDatabase;

namespace Server::MirObjects::Monsters
{

    bool Football::getCanAttack() const
    {
        return false;
    }

    Football::Football(MonsterInfo *info) : MonsterObject(info)
    {

    }

    void Football::FindTarget()
    {
    }

    void Football::ProcessTarget()
    {
    }

    bool Football::IsAttackTarget(MonsterObject *attacker)
    {
        return false;
    }

    int Football::Attacked(PlayerObject *attacker, int damage, DefenceType type, bool damageWeapon)
    {
        int currentMoveDistance = 0;

        Point *target = Functions::PointMove(getCurrentLocation(), attacker->getDirection(), _ballMoveDistance);

        MirDirection dir = Functions::DirectionFromPoint(getCurrentLocation(), target);

        while (currentMoveDistance < _ballMoveDistance)
        {
            Point *location = Functions::PointMove(getCurrentLocation(), dir, 1);

            if (location->X < 0 || location->Y < 0 || location->X >= getCurrentMap()->Width || location->Y >= getCurrentMap()->Height)
            {
                break;
            }

            currentMoveDistance++;

            if (!getCurrentMap()->GetCell(location)->getValid())
            {
                dir = Functions::ReverseDirection(dir);
                continue;
            }

            Walk(dir);
            MoveTime = 0;
            ActionTime = 0;
        }

        return 0;
    }

    int Football::Attacked(MonsterObject *attacker, int damage, DefenceType type)
    {
        throw NotSupportedException();
    }

    int Football::Struck(int damage, DefenceType type)
    {
        return 0;
    }

    void Football::Die()
    {
    }
}
